#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int count_lines(const char *filename);

int main()
{
    const char *filename="731_格式化.txt";
    int lines=count_lines(filename);
    printf("%d\n",lines);
    return 0;
}

int count_lines(const char *filename)
{
    FILE *fp=fopen(filename,"r");
    if(fp==NULL)
    {
        printf("文件打开失败");
        return -1;
    }
    int count = 0;
    char buffer[1024];

    for(size_t i=0;fgets(buffer,sizeof(buffer),fp)!=NULL;i++)
    {
        //if(buffer[i]=='\n')
        //{
            count++;
        //}
    }
    fclose(fp);
    return count;
}